#include "MyTree.h"
#include <iostream>
#include <boost\foreach.hpp>

MyTree::MyTree( void )
{
	root = NULL;
}

MyTree::~MyTree(void)
{
	if(root != NULL)
	{
		delete root;
		root = NULL;
	}
}

MyNode* MyTree::GetRoot()
{
	return root;
}

MyNode* MyTree::GetParent( MyNode* _node)
{
	return _node->GetParent();
}

std::vector<MyNode*> MyTree::GetChild( MyNode* _node)
{
	return _node->GetChildren();
}

void MyTree::PrintPreSelf()
{
	std::cout << "Print Pre Tree ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" << std::endl;
	if(this->root != NULL)
	{
		PrintPreSelf(root);
	}
}

void MyTree::PrintPreSelf(MyNode* parentNode)
{
	std::cout << parentNode->containFile->fileName << std::endl;
	BOOST_FOREACH(MyNode* node,parentNode->childrenNodes)
	{
		PrintPreSelf(node);
	}
}